package com.shwread.android.qysw.activity;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.shwread.android.qysw10000243.R;

import logic.bean.BookTicketRecordInfo;
import logic.beanenum.Ecard_Enum;
import logic.util.Util;

/**
 * 
 * @Project： Shwread
 * @Title：BookTicketDetailActivity
 * @Description：电子书券详情
 * @Author：wayne
 * @Date：2014年11月18日下午4:04:31
 */
public class BookTicketDetailActivity
        extends
        BaseBusinessActivity
        implements
        OnClickListener
{
	private Button               btnBack;
	private TextView             tvTitle;
	private Context              context;
	private BookTicketRecordInfo bean = null;
	
	private TextView             tvMounth, tvType, tvPeople, tvCardNumber, tvCardPwd, tvNumber, tvTime , tvGiveAccount;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.book_ticket_activate_detail);
		context = this;
		
		Bundle bundle = getIntent().getExtras();
		if (null != bundle)
		{
			bean = (BookTicketRecordInfo) bundle.getSerializable("BookTicketRecordInfo");
		}
		if (null == bean)
		{
			Util.showToast(context, "没有充值记录");
			finish();
		}
		
		initView();
		setListener();
		initData();
	}
	
	private void initData() {
		tvMounth.setText(getResources().getString(R.string.add_service_month, bean.getServiceMonthNum()));
		tvType.setText(Ecard_Enum.ACTIVATE.getValue().equals(bean.getBindType()) ? "激活" : "被赠送");
		tvGiveAccount.setVisibility(Ecard_Enum.ACTIVATE.getValue().equals(bean.getBindType())?View.GONE:View.VISIBLE);
		tvPeople.setVisibility(Ecard_Enum.ACTIVATE.getValue().equals(bean.getBindType())?View.GONE:View.VISIBLE);
		tvPeople.setText(bean.getGiveAccount());
		tvCardNumber.setText(bean.getCardDto().getCardNum());
		tvCardPwd.setText(bean.getCardDto().getCardPwd());
		tvTime.setText(Util.getFormatTime("yyyy-MM-dd hh:mm", bean.getCreateTime()));
		tvNumber.setText("" + bean.getRecorderId());
		
	}
	
	private void setListener() {
		btnBack.setOnClickListener(this);
	}
	
	private void initView() {
		btnBack = (Button) findViewById(R.id.common_header_back);
		btnBack.setVisibility(View.VISIBLE);
		tvTitle = (TextView) findViewById(R.id.common_header_name);
		tvTitle.setText("书券详情");
		
		tvCardNumber = (TextView) findViewById(R.id.book_ticket_activate_detail_card_tv);
		tvCardPwd = (TextView) findViewById(R.id.book_ticket_activate_detail_pwd_tv);
		tvType = (TextView) findViewById(R.id.book_ticket_activate_detail_type_tv);
		tvPeople = (TextView) findViewById(R.id.book_ticket_activate_detail_people_tv);
		tvGiveAccount = (TextView) findViewById(R.id.book_ticket_activate_detail_tv2);
		tvTime = (TextView) findViewById(R.id.book_ticket_activate_detail_time_tv);
		tvNumber = (TextView) findViewById(R.id.book_ticket_activate_detail_number_tv);
		tvMounth = (TextView) findViewById(R.id.book_ticket_activate_detail_mounth_tv);
		
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.common_header_back:
				onBackPressed();
				break;
			
			default:
				break;
		}
		
	}
	
	@Override
	public Handler getUIHandler() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
